//
//  FixThrowSetView.m
//  HaoDeCaiFu
//
//  Created by admin on 2017/12/23.
//  Copyright © 2017年 郑开宏. All rights reserved.
//

#import "FixThrowSetView.h"

@implementation FixThrowSetView
+(instancetype)fixTrowSetView
{
    return [[NSBundle mainBundle] loadNibNamed:@"FixThrowSetView" owner:nil options:nil].firstObject;
}
- (IBAction)nameTextFieldEditingDidEnd:(id)sender {
    _nameTextField = (UITextField *)sender;
    if ([_delegate respondsToSelector:@selector(fixThrowSetViewReturnNameTextfield:)]) {
        [_delegate fixThrowSetViewReturnNameTextfield:_nameTextField.text];
    }
    LLLog(@"%@",_nameTextField.text);
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    _periodLabel.userInteractionEnabled = YES;
    UITapGestureRecognizer * tapPeriodLabel = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(periodLabelClick)];
    [_periodLabel addGestureRecognizer:tapPeriodLabel];
    
    
    _dateLabel.userInteractionEnabled = YES;
    UITapGestureRecognizer * tapDateLabel = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dateLabelClick)];
    [_dateLabel addGestureRecognizer:tapDateLabel];
    
    
    _groupLabel.userInteractionEnabled = YES;
    UITapGestureRecognizer * tapGroupLabel = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(groupLabelClick)];
    [_groupLabel addGestureRecognizer:tapGroupLabel];
    
    
    _nameTextField.borderStyle = UITextBorderStyleNone;
    
    
    _trueImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer * trueIV = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(trueImageViewClick:)];
    [_trueImageView addGestureRecognizer:trueIV];
    
    
    _falseImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer * falseIV = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(falseImageViewClick:)];
    [_falseImageView addGestureRecognizer:falseIV];
}
//点击是（扣款失败顺延）
-(void)trueImageViewClick:(UITapGestureRecognizer *)tap
{
    UIImageView * iamgeView = (UIImageView *)tap.view;
    iamgeView.image = [UIImage imageNamed:@"xuanzhong_sel"];
    
    _falseImageView.image = [UIImage imageNamed:@"xuanzhong_dis"];
    if ([_delegate respondsToSelector:@selector(fixThrowSetViewReturnIndex:)]) {
        [_delegate fixThrowSetViewReturnIndex:3];
    }
}

//点击是（扣款失败顺延）
-(void)falseImageViewClick:(UITapGestureRecognizer *)tap
{
    UIImageView * iamgeView = (UIImageView *)tap.view;
    iamgeView.image = [UIImage imageNamed:@"xuanzhong_sel"];
    
    _trueImageView.image = [UIImage imageNamed:@"xuanzhong_dis"];
    if ([_delegate respondsToSelector:@selector(fixThrowSetViewReturnIndex:)]) {
        [_delegate fixThrowSetViewReturnIndex:4];
    }
}

-(void)periodLabelClick
{
    //LLLog(@"点击了每月");
    if ([_delegate respondsToSelector:@selector(fixThrowSetViewReturnIndex:)]) {
        [_delegate fixThrowSetViewReturnIndex:0];
    }
}
-(void)dateLabelClick
{
    //LLLog(@"点击了每日");
    if ([_delegate respondsToSelector:@selector(fixThrowSetViewReturnIndex:)]) {
        [_delegate fixThrowSetViewReturnIndex:1];
    }
}
-(void)groupLabelClick
{
    //LLLog(@"点击了个人投资项目");
    if ([_delegate respondsToSelector:@selector(fixThrowSetViewReturnIndex:)]) {
        [_delegate fixThrowSetViewReturnIndex:2];
    }
}
@end
